let Span = document.querySelectorAll(".Yihang span")
let pswBtn = document.querySelector(".box .shuRu")
let dxBtn = document.querySelector(".box .duanXin")
let ShouIps = document.querySelectorAll(".shuRu input")
let DuanIps = document.querySelectorAll(".duanXin input")

Span[0].onclick = function () {
  // console.log("第一个span");
  pswBtn.style.display = "block"
  Span[0].style.borderBottom = "2px solid black";
  Span[1].style.borderBottom = "none";
  dxBtn.style.display = "none"
}
Span[1].onclick = function () {
  // console.log("第二个span");
  Span[1].style.borderBottom = "2px solid black";
  Span[0].style.borderBottom = "none";
  pswBtn.style.display = "none"
  dxBtn.style.display = "block"
}

ShouIps[2].addEventListener("click", ShouBtn)
function ShouBtn() {
  console.log("密码登录按钮");
  let data = {
    username: ShouIps[0].value,
    password: ShouIps[1].value
  }
  axiosPost("/api/front/users/login", data).then((r) => {
    console.log(r.data);
    if (r.data.code == 1) {
      let { uid, token } = r.data
      //存入用户id token  到本地
      localStorage.setItem('uid', uid)
      localStorage.setItem('token', token)
      layui.use(function () {
        layui.layer.msg(r.data.msg)
      })
      setTimeout(() => {
        location.href = "./03-首页.html"
      }, 2000)

    } if (r.data.code == 0) {
      console.log(2);
      layui.use(function () {
        layui.layer.msg(r.data.msg)
      })
    }
  })
}

DuanIps[2].addEventListener("click", DuanBtn)
function DuanBtn() {
  console.log("短信登录按钮");

}
